import React, { useState, useEffect,useRef} from 'react';
import { Layout, Icon, Form, Button, Card,Input,message,Switch,Select } from 'antd'
import Child from './testChild.js'
import Child2 from './testChild2.js'
const {Option } = Select

export default function() { 

  const [count , setCount ] = useState(0)

  const childRef = useRef({});
  
  return (
    <div style={{ padding: 100}}>  

      <h3>react hooks 父子组件通信 count = { count} </h3> 

      <Child count ={count } setCount={setCount}/>

      
      <h3>父组件使用子组件数据 和方法 </h3> 
      https://www.cnblogs.com/muamaker/p/11647626.html
      <Child2  count ={count } ref={childRef} />
      <button onClick={()=>{
        console.log(childRef)
        childRef.current.handleLog();
        
        console.log(childRef.current.date) 
      }}>触发子组件方法</button>

    </div>
  );
}
